package com.gufe.mapper.admin.club;

import com.gufe.entity.PPTActiveQueryParam;
import com.gufe.entity.PrecollectMember;
import com.gufe.vo.PPTvo.ActiveMemberVO;
import com.gufe.vo.PPTvo.CollegeCountVO;
import com.gufe.vo.PPTvo.PersonInfoVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ActiveMemberMapper {
    /**
     * 分页条件查询预征班现役成员信息
     *
     * @param pptActiveQueryParam
     * @return
     */
    List<ActiveMemberVO> list(PPTActiveQueryParam pptActiveQueryParam);

    /**
     * 统计各个学院现役成员数
     *
     * @return
     */
    @Select("SELECT IFNULL(college, '未分配学院') AS college, COUNT(*) AS member_count FROM precollect_members " +
            "WHERE status = 1 GROUP BY college ORDER BY member_count DESC")
    List<CollegeCountVO> getCollegeCount();


    @Delete("delete from precollect_members where student_id = #{studentId}")
    void deleteByStudentId(String studentId);

    // 根据学号查询学生个人信息
    PrecollectMember getPrecollectMemberBystudentId(String studentId);

    // 根据Id查询学生个人信息
    @Select("select * from precollect_members where id = #{id}")
    PersonInfoVO getPrecollectMemberById(Integer id);
}
